package com.ruoyi.demo.service.base.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import com.ruoyi.demo.mapper.DemoProductMapper;
import com.ruoyi.demo.domain.DemoProduct;
import com.ruoyi.demo.service.base.DemoProductService;

import java.util.List;

/**
 * 产品Service业务层处理
 *
 * @author zhangshu
 * @date 2021-01-26
 */
@Service
public class DemoProductServiceImpl extends ServiceImpl<DemoProductMapper, DemoProduct> implements DemoProductService {

    @Override
    public List<DemoProduct> queryList(DemoProduct demoProduct) {
        LambdaQueryWrapper<DemoProduct> lqw = Wrappers.lambdaQuery();
        if (demoProduct.getParentId() != null){
            lqw.eq(DemoProduct::getParentId ,demoProduct.getParentId());
        }
        if (StringUtils.isNotBlank(demoProduct.getProductName())){
            lqw.like(DemoProduct::getProductName ,demoProduct.getProductName());
        }
        if (demoProduct.getOrderNum() != null){
            lqw.eq(DemoProduct::getOrderNum ,demoProduct.getOrderNum());
        }
        if (StringUtils.isNotBlank(demoProduct.getStatus())){
            lqw.eq(DemoProduct::getStatus ,demoProduct.getStatus());
        }
        return this.list(lqw);
    }
}
